﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.SYS.Bussiness;
using System.Data;
using ZX.BLL.Extend;
using ZX.EHR.Library;
using ZX.DBModule;
using ZX.BLL;
using System.Web.Security;
using ZX.SYS.Library;
using System.Text.RegularExpressions;
using System.Configuration;
using ZX.Web.Message;
namespace ZX.WebApp.Crm
{
    public partial class SendMessage : BasePage
    {
        BaseBussnies Bbussness = new BaseBussnies();  //业务处理类

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void btnsendOnClick(object sender, EventArgs e)
        {
            string userid = PM.Value;
            string users = txtPM.Value;
            string mesti = txtTitle.Value;
            string messa = txtMODEL.Value;
            string mesty = ddlSendmode.SelectedValue;
            if (messa.Length > 300)
            {
                Labmes.Text = "字数限制：消息字数超过300，请裁剪后发送！";
                return;
            }

            if (Save(mesty,mesti, messa, userid) == "1")
            {
                Labmes.Text = "发送成功！";
            }
            else
                Labmes.Text = "发送失败！";

        }
        /// <summary>
        /// 保存按钮
        /// </summary>
        /// <param name="messageType">信息类型</param>
        /// <param name="subject">主题</param>
        /// <param name="Content">内容</param>
        /// <param name="ReceiverIds">接收人Ids</param>
        public string Save(string messageType,  string subject, string Content, string ReceiverIds)
        {
            try
            {
                MessageManager back = new MessageManager(subject, Content, messageType, this.User.UserID, "U", ReceiverIds.TrimEnd(','));
                 
                //Assert.Inconclusive("无法验证不返回值的方法。");
                return back.Send();
            }
            catch
            {
                return "0";
            }
        }
    }
}